package com.huaxin.hxcloud.dialog;

import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.huaxin.hxcloud.R;
import com.huaxindata.common.base.HxBaseDialogFragment;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author songxf
 * @date 2018/6/21
 * @Desc 填写配件
 * Copyright HUAXIN DATA. All rights reserved.
 */
public class HxSPTWritePartsDialog extends HxBaseDialogFragment {
    @BindView(R.id.tv_title)
    TextView       mTvTitle;
    @BindView(R.id.rl_title)
    RelativeLayout mRlTitle;
    @BindView(R.id.et_des)
    EditText       mEtDes;
    @BindView(R.id.rl_content)
    LinearLayout   mRlContent;
    @BindView(R.id.bt_cancel)
    Button         mBtCancel;
    @BindView(R.id.bt_ok)
    Button         mBtOk;

    public void setOnWritePatsClickListener(OnWritePatsClickListener onWritePatsClickListener) {
        mOnWritePatsClickListener = onWritePatsClickListener;
    }

    private OnWritePatsClickListener mOnWritePatsClickListener;

    public interface OnWritePatsClickListener {
        void content(String content);
    }


    public static HxSPTWritePartsDialog newInstance() {

        Bundle args = new Bundle();

        HxSPTWritePartsDialog fragment = new HxSPTWritePartsDialog();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int setRootViewId() {
        return R.layout.dialog_write_parts;
    }

    @Override
    public void initData() {

    }

    @Override
    public int showPosition() {
        return Gravity.CENTER;
    }


    @OnClick({R.id.bt_cancel, R.id.bt_ok})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.bt_cancel:
                dismiss();
                break;
            case R.id.bt_ok:
                String desEt = mEtDes.getText().toString();
                if (mOnWritePatsClickListener != null) {
                    mOnWritePatsClickListener.content(desEt);
                    dismiss();
                }
                break;
            default:
                break;
        }
    }
}
